home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Developers / Gamma Fade v1.1.3 / Test App / gamma.h < prev    next >
Encoding:
Text File  |  1995-06-29  |  5.2 KB  |  112 lines  |  [TEXT/KAHL]

  1. // File "gamma.h" - Header for Altering the Gamma Tables of GDevices
  2.  
  3. // * ****************************************************************************** *
  4. //
  5. //    This library is intended as a general tool for manipulating the Gamma Tables
  6. //        of Graphics Devices, to ramp them up or down in order to achieve smooth
  7. //        screen fades. The source is included for programmers who want to convert
  8. //        the library to A4-based, but it is not commented for public consumption.
  9. //    The library defines 2 globals to save state data, but the entire Table 
  10. //        manipulation is performed with unlocked handles to be easy on your heap.
  11. //        The typical memory chunk is about 600 bytes for a 13" Monitor in 8-bit 
  12. //        depth, or about 1700 bytes for one in 24-bit color. Usage will vary.
  13. //    Of course, the Classic Mac cannot use Gamma Fades, only Mac II or later machines
  14. //        with attached monitors. (I don't know about the Color Classic tho’!). Also,
  15. //        GDevice manipulation needs to follow InitGraf() & InitWindows() calls.
  16. //    Please use the listed functions to see if you can use this code before you set
  17. //        it up. As usual, this stuff is not warranteed, guaranteed, or anything--
  18. //        use it at your own risk. It is not Apple-recommended for anything, but it
  19. //        worked for me, so there!
  20. //    
  21. //        Written:    12/17/92, Matt Slot, fprefect@engin.umich.edu                
  22. //        
  23. //        Updated:     3/13/93, MJS    (v1.1)                                            
  24. //                        •>    Updated the GammaAvail calls to be more honest.
  25. //                            Actually check to see if Grafix Devices are supported
  26. //                            on this machine w/o using Gestalt. Also, used the 
  27. //                            std. Toolbox calls to test the GDevice attributes.
  28. //                        •>    Removed extraneous calls to lock handles in several
  29. //                            locations.
  30. //                        •>    Fixed bug in DoOneGammaFade which failed if the device
  31. //                            could not be found in the list.
  32. //                        •>    Changed function prototypes to be more intuitive.
  33. //                        •>    Updated the descriptions in header file.
  34. //                        •>  Thanks to David Phillip Oster, oster@well.sf.ca.us,
  35. //                            for his numerous suggestions and criticisms. :)
  36. //        
  37. //        Updated:     11/9/93, MJS    (v1.1.1)                                    
  38. //                        •>    Fixed incompatibility with EvenBetterBusError...
  39. //                            OK, it was an obscure bug (dereferencing once too
  40. //                            often), but didnt seem to break except with EBBE.
  41. //        
  42. //        Updated:     11/9/93, MJS    (v1.1.2)                                    
  43. //                        •>    Left a Debugger() in the posted application.
  44. //    
  45. //        Updated:     6/29/95, MJS    (v1.1.3)                                    
  46. //                        •>    Updated IsGammaAvailable() routines to check for
  47. //                            Fixed CLUT devices... especially powerbooks.
  48. //    
  49. //        Oh yeah, this stuff is free to anyone interested in it.
  50. //
  51. // * ****************************************************************************** *
  52.  
  53. //    A quick signature
  54. #define kGammaUtilsSig    'GAMA'
  55.  
  56. //    To help check for compatibility
  57. #define kGetDeviceListTrapNum        0xAA29
  58.  
  59. // * ****************************************************************************** *
  60.  
  61. //    Internal data storage
  62. typedef struct globalGammas {
  63.     short size, dataOffset;
  64.     GammaTblHandle saved, hacked;
  65.     GDHandle theGDevice;
  66.     struct globalGammas **next;
  67.     } globalGammas, *globalGammasPtr, **globalGammasHdl;
  68.     
  69. // * ****************************************************************************** *
  70. // * ****************************************************************************** *
  71. // Function Prototypes
  72.  
  73. Boolean IsGammaAvailable(void);
  74. Boolean IsOneGammaAvailable(GDHandle theGDevice);
  75.  
  76. //    These routines help you determine whether you can use the Gamma Table Utils
  77. //        on the current machine. The first checks all attached monitors, and the 
  78. //        second just checks the indicated monitor. Each returns TRUE if you can 
  79. //        use the functions, or FALSE if you can't. • Note: Before calling any other
  80. //        Gamma Table function below, use this function to see if you are allowed.
  81.  
  82. // * ****************************************************************************** *
  83.  
  84. OSErr SetupGammaTools(void);
  85. OSErr DisposeGammaTools(void);
  86.  
  87. //    These routines must bracket any calls to the Gamma Table functions, perhaps
  88. //        at the head and tail of your main(). The first sets up the data structures
  89. //        necessary to save and restore the state of your monitors. The second
  90. //        disposes of all the internal data structures, but does not reset the
  91. //        monitors to their original states. Both return the error code if some
  92. //        part failed. 
  93.  
  94. // * ****************************************************************************** *
  95.  
  96. OSErr DoGammaFade(short percent);
  97. OSErr DoOneGammaFade(GDHandle theGDevice, short percent);
  98.  
  99. //    Use the first function to Fade each of your monitors to some percentage of their
  100. //        initial brightness (100 = bright, 0 = dim). Repeatedly call this to ramp your
  101. //        monitors up or down. The second function performs the same function, but only
  102. //        for the specified monitor. Both return any applicable error codes.
  103. //    Be sure to set up the necessary save-state data structures before you start by
  104. //        calling the compatibility and initialization functions. 
  105.  
  106. // * ****************************************************************************** *
  107.  
  108. OSErr GetDevGammaTable(GDHandle theGDevice, GammaTblPtr *theTable);
  109. OSErr SetDevGammaTable(GDHandle theGDevice, GammaTblPtr *theTable);
  110.  
  111. //    These routines are low-level interfaces to the device drivers for the monitors.
  112. //        Use them at your own risk.